package bishi.ruiming;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

/**
 * @author: 唐小尊
 * @email: 1171702529@qq.com
 * @cate: 2021/09/15 20:08
 */
public class two {
    public double findMedianSortedArrays (int[] nums1, int[] nums2) {
        List<Integer> list = new ArrayList<Integer>();
        for(int i:nums1){
            list.add(i);
        }
        for(int i:nums2){
            list.add(i);
        }
        list.sort(Comparator.comparingInt(i -> i));
        int p = nums1.length+nums2.length;
        if(p%2==1) return (double)list.get(p/2);
        else return (list.get(p/2-1)+list.get(p/2))*1.0/2;
    }
}
